﻿let Account = document.querySelector("#Account");
let Password = document.querySelector("#Password");

let LoginButton = document.querySelector(".LoginButton");

Account.addEventListener("keyup", function () {
    if (Account.value != "" && Password.value != "") {
        LoginButton.disabled = false;
    } else {
        LoginButton.disabled = true;
    }
});

Password.addEventListener("keyup", function () {
    if (Account.value != "" && Password.value != "") {
        LoginButton.disabled = false;
    } else {
        LoginButton.disabled = true;
    }
});

// 密码错误提示框
let ErrorLogin = document.querySelector("#ErrorLogin");
// 状态禁用提示框
let ErrorStatus = document.querySelector("#ErrorStatus");
// 登陆成功提示框
let LoginOk = document.querySelector("#LoginOk");



LoginButton.addEventListener("click", function () {
    var load = Peng.load({ box: 'Rows', content: '正在登录...', color: 'purple', style: 'circle' });




    $.post("/Login/Login", { Account: Account.value, Password: Password.value }).then((res) => {
        
        if (res.code === 0) {
            Peng.closeload(load);
     
         

            LoginOk.classList.add("Show");
            setTimeout(() => {
                LoginOk.classList.remove("Show");
                setTimeout(() => {

                    //setCookie("BSUID", Code.obj.BSUID, 30);

                    window.location = "/Index/Index";
                }, 200);
            }, 1500);



        } else {
            Peng.closeload(load);




            Peng.Show(res.message, { type: "Danger", Icon: true });
        }
    });
});



